package com.ruoyi.exam.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam.domain.ExamConflictLog;
import com.ruoyi.exam.service.IExamConflictLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 冲突检测日志管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/exam/conflictLog")
public class ExamConflictLogController extends BaseController
{
    @Autowired
    private IExamConflictLogService examConflictLogService;

    /**
     * 查询冲突检测日志管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:conflictLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamConflictLog examConflictLog)
    {
        startPage();
        List<ExamConflictLog> list = examConflictLogService.selectExamConflictLogList(examConflictLog);
        return getDataTable(list);
    }

    /**
     * 导出冲突检测日志管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:conflictLog:export')")
    @Log(title = "冲突检测日志管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamConflictLog examConflictLog)
    {
        List<ExamConflictLog> list = examConflictLogService.selectExamConflictLogList(examConflictLog);
        ExcelUtil<ExamConflictLog> util = new ExcelUtil<ExamConflictLog>(ExamConflictLog.class);
        util.exportExcel(response, list, "冲突检测日志管理数据");
    }

    /**
     * 获取冲突检测日志管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:conflictLog:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(examConflictLogService.selectExamConflictLogByLogId(logId));
    }

    /**
     * 新增冲突检测日志管理
     */
    @PreAuthorize("@ss.hasPermi('exam:conflictLog:add')")
    @Log(title = "冲突检测日志管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamConflictLog examConflictLog)
    {
        return toAjax(examConflictLogService.insertExamConflictLog(examConflictLog));
    }

    /**
     * 修改冲突检测日志管理
     */
    @PreAuthorize("@ss.hasPermi('exam:conflictLog:edit')")
    @Log(title = "冲突检测日志管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamConflictLog examConflictLog)
    {
        return toAjax(examConflictLogService.updateExamConflictLog(examConflictLog));
    }

    /**
     * 删除冲突检测日志管理
     */
    @PreAuthorize("@ss.hasPermi('exam:conflictLog:remove')")
    @Log(title = "冲突检测日志管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(examConflictLogService.deleteExamConflictLogByLogIds(logIds));
    }
}
